package com.example.ibsp_demo.mapper.message;

import com.example.ibsp_demo.pojo.entity.message.PrivateMessage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

@Mapper
public interface PrivateMessageMapper {

    // 插入私信消息
    int insert(PrivateMessage message);

    // 根据 sessionId 查询该会话下的所有私信
    List<PrivateMessage> selectBySessionId(@Param("sessionId") int sessionId,
                                           @Param("offset") int offset,
                                           @Param("pageSize") int pageSize);
    // 根据接收者ID和会话ID查询未读消息数量
    int countUnreadBySessionId(Map<String, Object> params);


    List<PrivateMessage> selectBySenderIdAndReceiverId(@Param("senderId") int senderId,
                                                       @Param("receiverId") int receiverId);

    // 标记会话内所有消息为已读（根据会话ID和接收者ID）
    int markAllReadBySessionId(@Param("sessionId") int sessionId,
                               @Param("receiverId") int receiverId);
    int deleteBySessionId(int sessionId);
    int deleteByMsgId(int messageId);
}
